Skip to content

Fix anonymous functions in hooks#158

Merged
lilactown merged 1 commit intolilactown:masterfrom
SevereOverfl0w:anon-fn
Jan 5, 2026
Merged

Fix anonymous functions in hooks#158
lilactown merged 1 commit intolilactown:masterfrom
SevereOverfl0w:anon-fn

Conversation

@SevereOverfl0w
Copy link
Contributor

Fix #117

(defn- normalise-sym
[x]
(if (symbol? x)
(symbol (string/replace (str x) #"^((p\d+|rest))(__\d+)#$" "$1__#"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this string/replace takes a value like p123__456# and returns p123__#, and this works because the pX number is related to the place within the form. Did I get that right?

I am curious if the pX is local to the binding form, or to the file, or global. I could see any of them being reasonable. I think best for us would be local to the binding form, because it would mean edits to other places in the same file/project wouldn't bust the fast refresh cache. I think no matter what, this is better than what we had before!

Copy link
Contributor Author

@SevereOverfl0w SevereOverfl0w Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first number is the index of the parameter, yep. So % corresponds to p1, so does %1. %2 corresponds to p2 etc.

And obviously %& corresponds to rest.

So local to the function bindings.

@lilactown lilactown merged commit bab74be into lilactown:master Jan 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gensym / anonymous function syntax breaks fast refresh

2 participants